<?php

GaAPI_Autoloader::instance()->load('GaAPI_Objects_Common_Object');


abstract class GaAPI_Objects_Common_Page extends GaAPI_Objects_Common_Object {

	public $totalNumEntries;
	public $PageType;
	public $entries;
	protected $_entries;

    public function  __set($name,  $value) {
        if ($name == 'Page.Type') {
            return $this->PageType = $value;
        }
        return  $this->$name = $value;
    }

    public function getType() {
        return str_replace('Page', '', $this->PageType);
    }


    public function getEntries() {
        if (!$this->_entries) {
            $this->_entries = $this->compileEntries();
        }
        return $this->_entries;
    }

    protected function compileEntries() {
        $entries = array();
        if ($this->entries) {
            if ($this->totalNumEntries == 1) {
                $this->entries = array($this->entries);
            }
            foreach ($this->entries as $entry) {
                $entryObj = $this->getNewEntry();
                $entryObj->setFromArray($entry);
                $entries[] = $entryObj;
            }
        }
        return $entries;
    }

}